home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Programming / gcc-2.95.3-3 / info / g77.info-3 < prev    next >
Encoding:
GNU Info File  |  2001-07-15  |  19.5 KB  |  456 lines

  1. This is Info file f/g77.info, produced by Makeinfo version 1.68 from
  2. the input file ./f/g77.texi.
  3.  
  4. INFO-DIR-SECTION Programming
  5. START-INFO-DIR-ENTRY
  6. * g77: (g77).                  The GNU Fortran compiler.
  7. END-INFO-DIR-ENTRY
  8.    This file documents the use and the internals of the GNU Fortran
  9. (`g77') compiler.  It corresponds to the GCC-2.95 version of `g77'.
  10.  
  11.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  12. Boston, MA 02111-1307 USA
  13.  
  14.    Copyright (C) 1995-1999 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License," "Funding for
  23. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  24. included exactly as in the original, and provided that the entire
  25. resulting derived work is distributed under the terms of a permission
  26. notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that the sections entitled "GNU General Public
  31. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  32. `Look And Feel'", and this permission notice, may be included in
  33. translations approved by the Free Software Foundation instead of in the
  34. original English.
  35.  
  36.    Contributed by James Craig Burley (<craig@jcb-sc.com>).  Inspired by
  37. a first pass at translating `g77-0.5.16/f/DOC' that was contributed to
  38. Craig by David Ronis (<ronis@onsager.chem.mcgill.ca>).
  39.  
  40. 
  41. File: g77.info,  Node: Code Gen Options,  Next: Environment Variables,  Prev: Directory Options,  Up: Invoking G77
  42.  
  43. Options for Code Generation Conventions
  44. =======================================
  45.  
  46.    These machine-independent options control the interface conventions
  47. used in code generation.
  48.  
  49.    Most of them have both positive and negative forms; the negative form
  50. of `-ffoo' would be `-fno-foo'.  In the table below, only one of the
  51. forms is listed--the one which is not the default.  You can figure out
  52. the other form by either removing `no-' or adding it.
  53.  
  54. `-fno-automatic'
  55.      Treat each program unit as if the `SAVE' statement was specified
  56.      for every local variable and array referenced in it.  Does not
  57.      affect common blocks.  (Some Fortran compilers provide this option
  58.      under the name `-static'.)
  59.  
  60. `-finit-local-zero'
  61.      Specify that variables and arrays that are local to a program unit
  62.      (not in a common block and not passed as an argument) are to be
  63.      initialized to binary zeros.
  64.  
  65.      Since there is a run-time penalty for initialization of variables
  66.      that are not given the `SAVE' attribute, it might be a good idea
  67.      to also use `-fno-automatic' with `-finit-local-zero'.
  68.  
  69. `-fno-f2c'
  70.      Do not generate code designed to be compatible with code generated
  71.      by `f2c'; use the GNU calling conventions instead.
  72.  
  73.      The `f2c' calling conventions require functions that return type
  74.      `REAL(KIND=1)' to actually return the C type `double', and
  75.      functions that return type `COMPLEX' to return the values via an
  76.      extra argument in the calling sequence that points to where to
  77.      store the return value.  Under the GNU calling conventions, such
  78.      functions simply return their results as they would in GNU
  79.      C--`REAL(KIND=1)' functions return the C type `float', and
  80.      `COMPLEX' functions return the GNU C type `complex' (or its
  81.      `struct' equivalent).
  82.  
  83.      This does not affect the generation of code that interfaces with
  84.      the `libg2c' library.
  85.  
  86.      However, because the `libg2c' library uses `f2c' calling
  87.      conventions, `g77' rejects attempts to pass intrinsics implemented
  88.      by routines in this library as actual arguments when `-fno-f2c' is
  89.      used, to avoid bugs when they are actually called by code
  90.      expecting the GNU calling conventions to work.
  91.  
  92.      For example, `INTRINSIC ABS;CALL FOO(ABS)' is rejected when
  93.      `-fno-f2c' is in force.  (Future versions of the `g77' run-time
  94.      library might offer routines that provide GNU-callable versions of
  95.      the routines that implement the `f2c'-callable intrinsics that may
  96.      be passed as actual arguments, so that valid programs need not be
  97.      rejected when `-fno-f2c' is used.)
  98.  
  99.      *Caution:* If `-fno-f2c' is used when compiling any source file
  100.      used in a program, it must be used when compiling *all* Fortran
  101.      source files used in that program.
  102.  
  103. `-ff2c-library'
  104.      Specify that use of `libg2c' (or the original `libf2c') is
  105.      required.  This is the default for the current version of `g77'.
  106.  
  107.      Currently it is not valid to specify `-fno-f2c-library'.  This
  108.      option is provided so users can specify it in shell scripts that
  109.      build programs and libraries that require the `libf2c' library,
  110.      even when being compiled by future versions of `g77' that might
  111.      otherwise default to generating code for an incompatible library.
  112.  
  113. `-fno-underscoring'
  114.      Do not transform names of entities specified in the Fortran source
  115.      file by appending underscores to them.
  116.  
  117.      With `-funderscoring' in effect, `g77' appends two underscores to
  118.      names with underscores and one underscore to external names with
  119.      no underscores.  (`g77' also appends two underscores to internal
  120.      names with underscores to avoid naming collisions with external
  121.      names.  The `-fno-second-underscore' option disables appending of
  122.      the second underscore in all cases.)
  123.  
  124.      This is done to ensure compatibility with code produced by many
  125.      UNIX Fortran compilers, including `f2c', which perform the same
  126.      transformations.
  127.  
  128.      Use of `-fno-underscoring' is not recommended unless you are
  129.      experimenting with issues such as integration of (GNU) Fortran into
  130.      existing system environments (vis-a-vis existing libraries, tools,
  131.      and so on).
  132.  
  133.      For example, with `-funderscoring', and assuming other defaults
  134.      like `-fcase-lower' and that `j()' and `max_count()' are external
  135.      functions while `my_var' and `lvar' are local variables, a
  136.      statement like
  137.  
  138.           I = J() + MAX_COUNT (MY_VAR, LVAR)
  139.  
  140.      is implemented as something akin to:
  141.  
  142.           i = j_() + max_count__(&my_var__, &lvar);
  143.  
  144.      With `-fno-underscoring', the same statement is implemented as:
  145.  
  146.           i = j() + max_count(&my_var, &lvar);
  147.  
  148.      Use of `-fno-underscoring' allows direct specification of
  149.      user-defined names while debugging and when interfacing
  150.      `g77'-compiled code with other languages.
  151.  
  152.      Note that just because the names match does *not* mean that the
  153.      interface implemented by `g77' for an external name matches the
  154.      interface implemented by some other language for that same name.
  155.      That is, getting code produced by `g77' to link to code produced
  156.      by some other compiler using this or any other method can be only a
  157.      small part of the overall solution--getting the code generated by
  158.      both compilers to agree on issues other than naming can require
  159.      significant effort, and, unlike naming disagreements, linkers
  160.      normally cannot detect disagreements in these other areas.
  161.  
  162.      Also, note that with `-fno-underscoring', the lack of appended
  163.      underscores introduces the very real possibility that a
  164.      user-defined external name will conflict with a name in a system
  165.      library, which could make finding unresolved-reference bugs quite
  166.      difficult in some cases--they might occur at program run time, and
  167.      show up only as buggy behavior at run time.
  168.  
  169.      In future versions of `g77', we hope to improve naming and linking
  170.      issues so that debugging always involves using the names as they
  171.      appear in the source, even if the names as seen by the linker are
  172.      mangled to prevent accidental linking between procedures with
  173.      incompatible interfaces.
  174.  
  175. `-fno-second-underscore'
  176.      Do not append a second underscore to names of entities specified
  177.      in the Fortran source file.
  178.  
  179.      This option has no effect if `-fno-underscoring' is in effect.
  180.  
  181.      Otherwise, with this option, an external name such as `MAX_COUNT'
  182.      is implemented as a reference to the link-time external symbol
  183.      `max_count_', instead of `max_count__'.
  184.  
  185. `-fno-ident'
  186.      Ignore the `#ident' directive.
  187.  
  188. `-fzeros'
  189.      Treat initial values of zero as if they were any other value.
  190.  
  191.      As of version 0.5.18, `g77' normally treats `DATA' and other
  192.      statements that are used to specify initial values of zero for
  193.      variables and arrays as if no values were actually specified, in
  194.      the sense that no diagnostics regarding multiple initializations
  195.      are produced.
  196.  
  197.      This is done to speed up compiling of programs that initialize
  198.      large arrays to zeros.
  199.  
  200.      Use `-fzeros' to revert to the simpler, slower behavior that can
  201.      catch multiple initializations by keeping track of all
  202.      initializations, zero or otherwise.
  203.  
  204.      *Caution:* Future versions of `g77' might disregard this option
  205.      (and its negative form, the default) or interpret it somewhat
  206.      differently.  The interpretation changes will affect only
  207.      non-standard programs; standard-conforming programs should not be
  208.      affected.
  209.  
  210. `-fdebug-kludge'
  211.      Emit information on `COMMON' and `EQUIVALENCE' members that might
  212.      help users of debuggers work around lack of proper debugging
  213.      information on such members.
  214.  
  215.      As of version 0.5.19, `g77' offers this option to emit information
  216.      on members of aggregate areas to help users while debugging.  This
  217.      information consists of establishing the type and contents of each
  218.      such member so that, when a debugger is asked to print the
  219.      contents, the printed information provides rudimentary debugging
  220.      information.  This information identifies the name of the
  221.      aggregate area (either the `COMMON' block name, or the
  222.      `g77'-assigned name for the `EQUIVALENCE' name) and the offset, in
  223.      bytes, of the member from the beginning of the area.
  224.  
  225.      Using `gdb', this information is not coherently displayed in the
  226.      Fortran language mode, so temporarily switching to the C language
  227.      mode to display the information is suggested.  Use `set language
  228.      c' and `set language fortran' to accomplish this.
  229.  
  230.      For example:
  231.  
  232.                 COMMON /X/A,B
  233.                 EQUIVALENCE (C,D)
  234.                 CHARACTER XX*50
  235.                 EQUIVALENCE (I,XX(20:20))
  236.                 END
  237.           
  238.           GDB is free software and you are welcome to distribute copies of it
  239.            under certain conditions; type "show copying" to see the conditions.
  240.           There is absolutely no warranty for GDB; type "show warranty" for details.
  241.           GDB 4.16 (lm-gnits-dwim), Copyright 1996 Free Software Foundation, Inc...
  242.           (gdb) b MAIN__
  243.           Breakpoint 1 at 0t1200000201120112: file cd.f, line 5.
  244.           (gdb) r
  245.           Starting program: /home/user/a.out
  246.           
  247.           Breakpoint 1, MAIN__ () at cd.f:5
  248.           Current language:  auto; currently fortran
  249.           (gdb) set language c
  250.           Warning: the current language does not match this frame.
  251.           (gdb) p a
  252.           $2 = "At (COMMON) `x_' plus 0 bytes"
  253.           (gdb) p b
  254.           $3 = "At (COMMON) `x_' plus 4 bytes"
  255.           (gdb) p c
  256.           $4 = "At (EQUIVALENCE) `__g77_equiv_c' plus 0 bytes"
  257.           (gdb) p d
  258.           $5 = "At (EQUIVALENCE) `__g77_equiv_c' plus 0 bytes"
  259.           (gdb) p i
  260.           $6 = "At (EQUIVALENCE) `__g77_equiv_xx' plus 20 bytes"
  261.           (gdb) p xx
  262.           $7 = "At (EQUIVALENCE) `__g77_equiv_xx' plus 1 bytes"
  263.           (gdb) set language fortran
  264.           (gdb)
  265.  
  266.      Use `-fdebug-kludge' to generate this information, which might
  267.      make some programs noticeably larger.
  268.  
  269.      *Caution:* Future versions of `g77' might disregard this option
  270.      (and its negative form).  Current plans call for this to happen
  271.      when published versions of `g77' and `gdb' exist that provide
  272.      proper access to debugging information on `COMMON' and
  273.      `EQUIVALENCE' members.
  274.  
  275. `-femulate-complex'
  276.      Implement `COMPLEX' arithmetic via emulation, instead of using the
  277.      facilities of the `gcc' back end that provide direct support of
  278.      `complex' arithmetic.
  279.  
  280.      (`gcc' had some bugs in its back-end support for `complex'
  281.      arithmetic, due primarily to the support not being completed as of
  282.      version 2.8.1 and `egcs' 1.1.2.)
  283.  
  284.      Use `-femulate-complex' if you suspect code-generation bugs, or
  285.      experience compiler crashes, that might result from `g77' using
  286.      the `COMPLEX' support in the `gcc' back end.  If using that option
  287.      fixes the bugs or crashes you are seeing, that indicates a likely
  288.      `g77' bugs (though, all compiler crashes are considered bugs), so,
  289.      please report it.  (Note that the known bugs, now believed fixed,
  290.      produced compiler crashes rather than causing the generation of
  291.      incorrect code.)
  292.  
  293.      Use of this option should not affect how Fortran code compiled by
  294.      `g77' works in terms of its interfaces to other code, e.g. that
  295.      compiled by `f2c'.
  296.  
  297.      *Caution:* Future versions of `g77' might ignore both forms of
  298.      this option.
  299.  
  300. `-falias-check'
  301.  
  302. `-fargument-alias'
  303.  
  304. `-fargument-noalias'
  305.  
  306. `-fno-argument-noalias-global'
  307.      *Version info:* These options are not supported by versions of
  308.      `g77' based on `gcc' version 2.8.
  309.  
  310.      These options specify to what degree aliasing (overlap) is
  311.      permitted between arguments (passed as pointers) and `COMMON'
  312.      (external, or public) storage.
  313.  
  314.      The default for Fortran code, as mandated by the FORTRAN 77 and
  315.      Fortran 90 standards, is `-fargument-noalias-global'.  The default
  316.      for code written in the C language family is `-fargument-alias'.
  317.  
  318.      Note that, on some systems, compiling with `-fforce-addr' in
  319.      effect can produce more optimal code when the default aliasing
  320.      options are in effect (and when optimization is enabled).
  321.  
  322.      *Note Aliasing Assumed To Work::, for detailed information on the
  323.      implications of compiling Fortran code that depends on the ability
  324.      to alias dummy arguments.
  325.  
  326. `-fno-globals'
  327.      Disable diagnostics about inter-procedural analysis problems, such
  328.      as disagreements about the type of a function or a procedure's
  329.      argument, that might cause a compiler crash when attempting to
  330.      inline a reference to a procedure within a program unit.  (The
  331.      diagnostics themselves are still produced, but as warnings, unless
  332.      `-Wno-globals' is specified, in which case no relevant diagnostics
  333.      are produced.)
  334.  
  335.      Further, this option disables such inlining, to avoid compiler
  336.      crashes resulting from incorrect code that would otherwise be
  337.      diagnosed.
  338.  
  339.      As such, this option might be quite useful when compiling
  340.      existing, "working" code that happens to have a few bugs that do
  341.      not generally show themselves, but which `g77' diagnoses.
  342.  
  343.      Use of this option therefore has the effect of instructing `g77'
  344.      to behave more like it did up through version 0.5.19.1, when it
  345.      paid little or no attention to disagreements between program units
  346.      about a procedure's type and argument information, and when it
  347.      performed no inlining of procedures (except statement functions).
  348.  
  349.      Without this option, `g77' defaults to performing the potentially
  350.      inlining procedures as it started doing in version 0.5.20, but as
  351.      of version 0.5.21, it also diagnoses disagreements that might
  352.      cause such inlining to crash the compiler as (fatal) errors, and
  353.      warns about similar disagreements that are currently believed to
  354.      not likely to result in the compiler later crashing or producing
  355.      incorrect code.
  356.  
  357. `-fflatten-arrays'
  358.      Use back end's C-like constructs (pointer plus offset) instead of
  359.      its `ARRAY_REF' construct to handle all array references.
  360.  
  361.      *Note:* This option is not supported.  It is intended for use only
  362.      by `g77' developers, to evaluate code-generation issues.  It might
  363.      be removed at any time.
  364.  
  365. `-fbounds-check'
  366. `-ffortran-bounds-check'
  367.      Enable generation of run-time checks for array subscripts and
  368.      substring start and end points against the (locally) declared
  369.      minimum and maximum values.
  370.  
  371.      The current implementation uses the `libf2c' library routine
  372.      `s_rnge' to print the diagnostic.
  373.  
  374.      However, whereas `f2c' generates a single check per reference for
  375.      a multi-dimensional array, of the computed offset against the
  376.      valid offset range (0 through the size of the array), `g77'
  377.      generates a single check per *subscript* expression.  This catches
  378.      some cases of potential bugs that `f2c' does not, such as
  379.      references to below the beginning of an assumed-size array.
  380.  
  381.      `g77' also generates checks for `CHARACTER' substring references,
  382.      something `f2c' currently does not do.
  383.  
  384.      Use the new `-ffortran-bounds-check' option to specify
  385.      bounds-checking for only the Fortran code you are compiling, not
  386.      necessarily for code written in other languages.
  387.  
  388.      *Note:* To provide more detailed information on the offending
  389.      subscript, `g77' provides the `libg2c' run-time library routine
  390.      `s_rnge' with somewhat differently-formatted information.  Here's
  391.      a sample diagnostic:
  392.  
  393.           Subscript out of range on file line 4, procedure rnge.f/bf.
  394.           Attempt to access the -6-th element of variable b[subscript-2-of-2].
  395.           Aborted
  396.  
  397.      The above message indicates that the offending source line is line
  398.      4 of the file `rnge.f', within the program unit (or statement
  399.      function) named `bf'.  The offended array is named `b'.  The
  400.      offended array dimension is the second for a two-dimensional array,
  401.      and the offending, computed subscript expression was `-6'.
  402.  
  403.      For a `CHARACTER' substring reference, the second line has this
  404.      appearance:
  405.  
  406.           Attempt to access the 11-th element of variable a[start-substring].
  407.  
  408.      This indicates that the offended `CHARACTER' variable or array is
  409.      named `a', the offended substring position is the starting
  410.      (leftmost) position, and the offending substring expression is
  411.      `11'.
  412.  
  413.      (Though the verbage of `s_rnge' is not ideal for the purpose of
  414.      the `g77' compiler, the above information should provide adequate
  415.      diagnostic abilities to it users.)
  416.  
  417.    *Note Options for Code Generation Conventions: (gcc)Code Gen
  418. Options, for information on more options offered by the GBE shared by
  419. `g77', `gcc', and other GNU compilers.
  420.  
  421.    Some of these do *not* work when compiling programs written in
  422. Fortran:
  423.  
  424. `-fpcc-struct-return'
  425.  
  426. `-freg-struct-return'
  427.      You should not use these except strictly the same way as you used
  428.      them to build the version of `libg2c' with which you will be
  429.      linking all code compiled by `g77' with the same option.
  430.  
  431. `-fshort-double'
  432.      This probably either has no effect on Fortran programs, or makes
  433.      them act loopy.
  434.  
  435. `-fno-common'
  436.      Do not use this when compiling Fortran programs, or there will be
  437.      Trouble.
  438.  
  439. `-fpack-struct'
  440.      This probably will break any calls to the `libg2c' library, at the
  441.      very least, even if it is built with the same option.
  442.  
  443. 
  444. File: g77.info,  Node: Environment Variables,  Prev: Code Gen Options,  Up: Invoking G77
  445.  
  446. Environment Variables Affecting GNU Fortran
  447. ===========================================
  448.  
  449.    GNU Fortran currently does not make use of any environment variables
  450. to control its operation above and beyond those that affect the
  451. operation of `gcc'.
  452.  
  453.    *Note Environment Variables Affecting GNU CC: (gcc)Environment
  454. Variables, for information on environment variables.
  455.  
  456.